/**
 * 
 */
package com.misoo.ex06;

import java.util.ArrayList;
import java.util.Map;

import android.app.ListActivity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

/**
 * @author daniel.chai
 * 
 */
public class ex06_a extends ListActivity {
	private DataModel dm;
	private ArrayList<Map<String, Object>> coll;

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		dm = new DataModel();
		coll = dm.loadData();
		this.setListAdapter(new SimpleAdapter(this, coll,
				android.R.layout.simple_list_item_1,
				new String[] { "prod_na" }, new int[] { android.R.id.text1 }));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.ListActivity#onListItemClick(android.widget.ListView,
	 * android.view.View, int, long)
	 */
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		super.onListItemClick(l, v, position, id);
		setTitleColor(Color.GREEN);
		setTitle(coll.get(position).get("prod_type").toString());
	}

}
